package day03;

/**
 * @author yzh
 * @desc TODO
 * @date 2025/4/9
 */
public class Test05 {
    public static void main(String[] args) {
        int count = 0; // 统计水仙花数个数

        System.out.println("三位数中的水仙花数有：");

        for (int num = 100; num <= 999; num++) {
            int unit = num % 10;           // 个位数
            int ten = (num / 10) % 10;    // 十位数
            int hundred = num / 100;      // 百位数

            // 计算各位数字立方和
            int sum = hundred * hundred * hundred
                    + ten * ten * ten
                    + unit * unit * unit;

            // 判断是否为水仙花数
            if (sum == num) {
                System.out.print(num + " ");
                count++;
            }
        }

        System.out.println("\n水仙花数的总个数为：" + count);
    }
}
